{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "de515fbe-d363-4529-b97a-ce5c301eca97",
   "metadata": {},
   "source": [
    "# 下载Labelme样例数据集\n",
    "\n",
    "同济子豪兄 2023-4-15\n",
    "\n",
    "SJB_25_Dataset数据集，包含25张30度直角三角板的图像，标注了以下信息：\n",
    "\n",
    "- 目标检测框：30度直角三角板（sjb_rect）\n",
    "\n",
    "- 关键点：30度角点、60角点、90度角点（Angle_30、Angle_60、Angle_90）\n",
    "\n",
    "- 多段线分割：30度直角三角板区域（sjb_poly）"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "ea319711-ab92-47b3-add4-034a78240ce2",
   "metadata": {},
   "source": [
    "## 下载数据集"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "b4209274-5901-4b07-97b7-0fe006144500",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "--2023-04-25 10:21:22--  https://zihao-download.obs.cn-east-3.myhuaweicloud.com/yolov8/datasets/SJB_25_Dataset.zip\n",
      "正在连接 172.16.0.13:5848... 已连接。\n",
      "已发出 Proxy 请求，正在等待回应... 200 OK\n",
      "长度： 80856957 (77M) [application/zip]\n",
      "正在保存至: “SJB_25_Dataset.zip”\n",
      "\n",
      "SJB_25_Dataset.zip  100%[===================>]  77.11M  31.6MB/s    用时 2.4s    \n",
      "\n",
      "2023-04-25 10:21:25 (31.6 MB/s) - 已保存 “SJB_25_Dataset.zip” [80856957/80856957])\n",
      "\n"
     ]
    }
   ],
   "source": [
    "!rm -rf SJB_25_Dataset.zip SJB_25_Dataset\n",
    "!wget https://zihao-download.obs.cn-east-3.myhuaweicloud.com/yolov8/datasets/SJB_25_Dataset.zip"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "60575f72-06af-494d-ac27-78b22890f4d3",
   "metadata": {},
   "source": [
    "## 解压数据集"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "2d3c481a-abd8-4474-8645-959a0c8c1759",
   "metadata": {},
   "outputs": [],
   "source": [
    "# 解压\n",
    "!unzip SJB_25_Dataset.zip >> /dev/null\n",
    "\n",
    "# 删除压缩包\n",
    "!rm -rf SJB_25_Dataset.zip"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "b9ba3f2d-d023-441d-84e2-1d2a2670337b",
   "metadata": {},
   "source": [
    "## 删除系统自动生成的多余文件"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "6a76103d-50fb-4860-b5ab-46640a190a03",
   "metadata": {},
   "source": [
    "### 查看待删除的多余文件"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "ebed5193-bfbe-45a1-9978-0cb113d69580",
   "metadata": {},
   "outputs": [],
   "source": [
    "!find . -iname '__MACOSX'"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "66adffc8-c541-42d3-b96d-3c01adcf6892",
   "metadata": {},
   "outputs": [],
   "source": [
    "!find . -iname '.DS_Store'"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "id": "ed59a496-0715-4577-88d4-5673c1817323",
   "metadata": {},
   "outputs": [],
   "source": [
    "!find . -iname '.ipynb_checkpoints'"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "a46a981b-380b-4871-a957-d1239aae6936",
   "metadata": {},
   "source": [
    "### 删除多余文件"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "id": "ea529397-5357-4ce7-b329-1336d6788c44",
   "metadata": {},
   "outputs": [],
   "source": [
    "!for i in `find . -iname '__MACOSX'`; do rm -rf $i;done"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "id": "97f237e2-9c6f-4df3-b9e1-abda38cc6f1f",
   "metadata": {},
   "outputs": [],
   "source": [
    "!for i in `find . -iname '.DS_Store'`; do rm -rf $i;done"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "id": "3f57d55b-10f1-4200-b31c-7e4abd1b3cb3",
   "metadata": {},
   "outputs": [],
   "source": [
    "!for i in `find . -iname '.ipynb_checkpoints'`; do rm -rf $i;done"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "395c55b1-b633-4536-9c7d-21dec853aa41",
   "metadata": {},
   "source": [
    "### 验证多余文件已删除"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "id": "13c550e3-f952-46c8-bd1d-40467016ccbc",
   "metadata": {},
   "outputs": [],
   "source": [
    "!find . -iname '__MACOSX'"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "id": "6f0db68e-3ed1-4aca-8ca7-e77f3c80d3be",
   "metadata": {},
   "outputs": [],
   "source": [
    "!find . -iname '.DS_Store'"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "id": "b1c6c99d-92c9-4dbb-8047-0876b844b61f",
   "metadata": {},
   "outputs": [],
   "source": [
    "!find . -iname '.ipynb_checkpoints'"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "60dbc0af-4d07-4b07-9682-574313619779",
   "metadata": {},
   "source": [
    "## 查看数据集目录结构"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "id": "3f3a441c-3eee-4dbd-90f1-b6f5d4338a89",
   "metadata": {},
   "outputs": [],
   "source": [
    "# !pip install seedir emoji"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "137c3bf1-221f-413f-bb12-dfc2e2e4ba21",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "📁 SJB_25_Dataset/\n",
      "├─📁 images/\n",
      "└─📁 labelme_jsons/\n"
     ]
    }
   ],
   "source": [
    "import seedir as sd\n",
    "sd.seedir('SJB_25_Dataset', style='emoji', depthlimit=1)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "ecbeccfb-8926-42dd-9d80-433c544084e9",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.10"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
